//
//  VisitorTableViewController.swift
//  swiftImitationWeibo
//
//  Created by 杨果果 on 16/7/9.
//  Copyright © 2016年 yang. All rights reserved.
//

import UIKit

class VisitorTableViewController: UITableViewController {
    var isLogin: Bool = UserAccountViewModel.sharedUserAccountViewModel.isLogin
    var vistorView: VistorView?
    override func loadView() {
        if isLogin{
            super.loadView()
        }else{
            //没有登录
            vistorView = VistorView()
            vistorView?.clourse = { [weak self] in
                print("点击了 访客视图")
                self?.showOAuth()
        }
            view = vistorView
//            setupUI()
            setupNavUI()
        }
    }
    private func setupNavUI() {
        //定义左右按钮
//        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self
//            , action: "registerAction")
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "registerAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self
            , action: "loginAction")
    }
    
    @objc private func registerAction(){
        print("注册")
        showOAuth()
    }
    @objc private func loginAction(){
        print("登录")
        showOAuth()
    }
    
    private func showOAuth(){
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    
    
    
    
    
    
    
    
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }

}
